class Rate {
    constructor (elem) {
        this.star = elem.find('.icon-star');
        this.input = elem.find('input[type=hidden]');
        this.rate = 0;
        this.bindEvent();
    }
    bindEvent () {
        this.star.on('click', (ev) => {
            this.rate = $(ev.currentTarget).index() + 1;
            this.setStar();
        });
    }
    setStar () {
        this.star.removeClass('active');
        $.each(this.star, (ind, val) => {
            ind < this.rate && $(val).addClass('active');
        });
        this.input.val(this.rate);
    }
    get Rate () {
        return this.rate;
    }
    set Rate (value) {
        this.rate = value;
        this.setStar();
    }
}